package exception;

import com.sun.org.apache.bcel.internal.generic.FieldGen;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/*
  异常处理机制在io中的操作
 */
public class FinallyDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fin = null;
        try {
            fin = new FileOutputStream("fos.txt");
            fin.write(1);

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (fin != null) {
                    fin.close();
                }
                ;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

}
